import React, { Component } from 'react';
import Taro from '@tarojs/taro';
import {View} from '@tarojs/components'
import {http} from "../../utils/http";
import {TARO_ENV, UN_LIMIT_URL} from "../../constants/api";

export default class MiddlePage extends Component {

  async UNSAFE_componentWillMount() {
    Taro.showLoading({title: "加载中", mask: true})
    const res = await http.HGet(UN_LIMIT_URL + (this.params.uuid || this.params.scene || ''))
    Taro.hideLoading()
    if (res && res.data) {
      const url = res.data
      if (TARO_ENV === 'h5') {
        window.location.replace(url)
      } else {
        if (url.startsWith('pages/index/big') || url.startsWith('pages/index/index') || url.startsWith('pages/my/index/index')) {
          Taro.switchTab({url: '/' + url})
        }else {
          Taro.navigateTo({
            url: '/' + url
          })
        }
      }
    }
  }

  params = Taro.getCurrentInstance().router.params

  render() {
    return (
      <View />
    )
  }
}
